<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>{$title}</h2>
        <ol class="breadcrumb">
            <li>
                <a href="#">首页</a>
            </li>

            <li class="active">
                <strong>{$title}</strong>
            </li>
        </ol>
    </div>

</div>

<div class="wrapper wrapper-content animated fadeInRight ecommerce">

    <div class="ibox-content m-b-sm border-bottom" id="form1">
        <div class="row">
            {volist name="fields" id="vo"}
            {if condition="$vo.field neq 'id' && $vo.field neq 'create_time'"}
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="{$vo.field}">{$vo.title}</label>
                    {if condition="$vo.type eq 'select'"}
                    <select id="{$vo.field}" name="{$vo.field}"
                            class="form-control">
                        <option value="">---请选择---</option>
                        {volist name="$vo.options" id="s"}
                        <option value="{$key}">{$s}</option>
                        {/volist}
                    </select>
                    {else/}
                    <input type="text" id="{$vo.field}" name="{$vo.field}" placeholder="{$vo.title}"
                           class="form-control">
                    {/if}
                </div>
            </div>
            {/if}
            {/volist}
        </div>
        <div class="row">
            <div class="col-sm-6">
                <a class="btn btn-success btn-outline" href="#{literal}{:U('form')}{/literal}">
                    <i class="fa fa-edit"></i>
                    <span class="bold">添加</span>
                </a>
            </div>
            <div class="col-sm-6 text-right">
                <button class="btn btn-default" data-op="reset">
                    <i class="fa fa-refresh"></i>
                    <span class="bold">重置</span>
                </button>
                &nbsp;
                &nbsp;
                <button class="btn btn-primary" data-op="search">
                    <i class="fa fa-search"></i>
                    <span class="bold">查询</span>
                </button>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-content">
                    <table class="footable table table-stripped toggle-arrow-tiny" id="footable">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
{php}
$columns = '';
foreach($fields as $k=>$v){
$column= '{';
if(empty($v['title']) || empty($v['field']) || $v['field'] == 'id'){
continue;
}
foreach(['field','title','formatter','options'] as $field){
if(!empty($v[$field])){
if($column!='{'){
$column .= ',';
}
if($field == 'field' || $field == 'title' || $field == 'title'){
$column .= ($field=='field'?'name':$field).':\''.$v[$field]."'";
}else{
if($field=='formatter' && $v[$field] == 'image'){
$column .= $field.':\''.$v[$field].'\'';
}else{
$column .= $field.':'.$v[$field];
}
}
}
}
if($k <= 1){
$column .= ",sortable: true";
}elseif($k >= 5){
$column .= ",sortable: true,breakpoints:'xs sm md'";
}else{
$column .= ",sortable: true,breakpoints:'xs sm md'";
}
$column .= '}';
if(!empty($columns)){
$columns .= "\n\t\t\t\t,";
}
$columns .= $column;
}
$columns.="\n";
{/php}
<script>
    $(document).ready(function () {
        YFootTable.create('#footable', {
            baseUrl: "{literal}{:U('{/literal}{$name}/')}",
            searchForm: '#form1',
            columns: [
                {$columns}
            ],
            actions: ['view', 'edit', 'remove']
        });
    });
</script>